import React from 'react';
import FormEnhance, {InputSwitch, InputText, SelectEnhance} from "common/form";
import {SecurityPath} from "type/entity/SecurityPath";
import {fetchAddPath} from "storage/redux/async-action/pathAsyncAction";
import LogFactory from "log/LogFactory";
import PathSelectHandler from "./PathSelectHandler";
import {methodOption} from "../menu";

const log = LogFactory.getLogger("PathAddComponent");
const PathAddComponent = () => {

    return (
        <FormEnhance<SecurityPath>
            title={"添加路径信息"}
            backupText={"路径列表"}
            requestAction={fetchAddPath}
            initialValues={{
                parentId: 1040000001,
                last: true,
                method: "ANY"
            }}
        >
            <PathSelectHandler/>
            <InputText<SecurityPath> name={"pattern"} label={"路径匹配模式"} required={true}/>
            <InputText<SecurityPath> name={"explain"} label={"路径说明"} required={true}/>
            <InputText<SecurityPath> name={"server"} label={"服务名"} required={true}/>
            <SelectEnhance<SecurityPath> name={"method"} label={"请求方法"} option={methodOption}/>
            <InputSwitch<SecurityPath> name={"last"} label={"子路径"} />
        </FormEnhance>
    );
};

export default PathAddComponent;